import { useDetail, useList } from "@/hooks";
import { onMounted, ref } from "vue";
import { getUserInfoUrl, getUserTypeValue } from "@/command/apiTool";
import { getAction } from "@/command/netTool";
import { IFetchPageListConfig } from "@/hooks/list";
import * as vant from "vant";
const { showSuccessToast } = vant

export const useRequest = () => {
  const page = ref<IFetchPageListConfig>()
  // 我的品牌
  const [myBrandInfo] = useDetail(
    getUserInfoUrl({
      dh: "/api/H5/sell/brand/heavy/myBrandInfo",
      xh: "/api/H5/sell/brand/small/myLeadInfo",
    }),
    {
      id: "",
      address: "",
      area: "",
      introduce: "",
      logoUrl: "",
      major: "",
      majorName: "",
      name: "",
      phone: "",
      town: "",
    }
  );

  // 最新咨讯-小户独有
  const [newInfo] = useDetail(
    getUserInfoUrl({
      dh: "",
      xh: "/api/H5/sell/brand/small/newInfo",
    }),
    {
      phone: "",
      typeName: "",
      beforeTime: "",
    }
  );

  // 申请/品牌列表
  // const [list] = useList(
  //   getUserInfoUrl({
  //     dh: "/api/H5/sell/brand/heavy/listApply",
  //     xh: "/api/H5/sell/brand/small/listBrand",
  //   })
  // );

  const agreeOrReject = (id: any, stats: any) => {
    getAction(`/api/H5/sell/brand/heavy/agreeOrReject?id=${id}&stats=${stats}`).then((e) => {
      // console.log('e', e)
      showSuccessToast(stats == '1' ? '申请成功' : '成功拒绝')
      page.value?.reset()
    })
  }

  return {
    // list,
    myBrandInfo,
    newInfo,
    agreeOrReject,
    page
  };
};
